<%@page contentType="text/html;charset=UTF-8"%>
<%@page pageEncoding="UTF-8"%>
<%@ include file="/pub/includ.jsp"%>
<html>
	<head>
		<script type="text/javascript">
		
			$(function(){
				//加载两个要使用json分页的组�?
		        loadGird("frm", 1);
			})
			
			var checkedIds="$";
			
			var getselectids = function(){
				return checkedIds.split("$")[0];
			}
			var callback_frm = function(rows, frm) {
		       $.each(rows, function(i, n){
		    	   var row = $("#"+frm+" .template").clone().removeClass("template");
		   			       var keyValue = n.id;
			       row.find(".klId").attr("id",n.id);
			       
			       row.find(".klId").attr("value",n.art_name);
			   	
			       row.find(".klart_name").text(n.art_name);
			   	
			       row.find(".klcreate_time").text(n.create_time);
			   	
		 		   row.attr("id","ready"+i);
		           row.attr("class","tr_nbw");
		           row.appendTo("#"+frm+" .grid");
		       });   
			}
			
			function _checkArt(obj){
			    var id = obj.id;
			    var userName = obj.value;
		    	var thisUser = document.getElementById(id);
		    	//userid1|userid2|userid3|$username|&username2|username3|
		    	var checkedStrs = checkedIds;
		    	if(checkedStrs == ""){
		    		if(thisUser.checked){
			    		checkedStrs = id+"|$"+userName+"|";
			    	}
				}else{
					if(thisUser.checked){
						if(checkedStrs.indexOf(id+"|") == -1){
							var indexNum = checkedStrs.indexOf("$");
				    		var before = checkedStrs.substring(0,indexNum);
				    		var behind = checkedStrs.substring(indexNum);
				    		checkedStrs = before + id +"|"+ behind + userName + "|";
						}
			    	}else{
			    		if(checkedStrs.indexOf(id+"|") != -1){
				    		var indexId = checkedStrs.indexOf(id+"|");
				    		var beginId = checkedStrs.substring(0,indexId);
				    		var endId = checkedStrs.substring(indexId + id.length +1);
				    		checkedStrs = beginId + endId;
				    		
				    		var indexName = checkedStrs.indexOf(userName+"|");
				    		var beginName = checkedStrs.substring(0,indexName);
				    		var endName = checkedStrs.substring(indexName + userName.length +1);
				    		checkedStrs = beginName + endName;
				    	}
			    	}
				}
		    	checkedIds = checkedStrs;
		    	
		    	var all = document.getElementById("selAll");
				if(!thisUser.checked) all.checked = false;
			  	else{
			    	var aa = document.getElementsByName("checkArt");
			    	for (var i=1; i<aa.length; i++)
			     		if(!aa[i].checked) return;
			    		all.checked = true;
			  	}
		    }
		    
		</script>
	</head>
<body style="OVERFLOW-Y:HIDDEN;">
<form name="frm" method="post" style="margin: 0" action="<%=path%>/cms/artgroup/artlst" id="frm">
		<center>
		<table><tr><td height="2px"></td></tr></table>
		<table border="0" cellspacing="1" cellpadding="0" class="table_nbw  niceTable grid">
			<thead class="th_nbw">
				<tr >
					<td width="40px" >
						<input type="checkbox" name="selAll" id="selAll" class="allCheck" />
					</td>
		      		<td>
						文章名称
					</td>   
		      		<td>
						创建时间
					</td>   
				</tr>
			</thead>
			<tbody>
				<tr class="template klId">
					<td width="40px" class="idCheck">
						<input type="checkbox" onclick="_checkArt(this)" name="checkArt" class="klId" />
					</td>
		   		    <td class="klart_name niceTable-left"></td>
		   		    <td class="klcreate_time niceTable-left"></td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td style="border-right: none">
						<img class="loading"
							src="/resources/skins/default/images/large-loading.gif" width="20px"
							class="hidden" />
					</td>
					<td colspan="2" style="border-left: none" class="txtRight">
						<span class="pagediv"></span>
					</td>
				</tr>
			</tfoot>
		</table>
		</center>
	</form>
</body>
</html>
